#!/bin/sh

# +++ 变量声明 Start+++
export g_libId="ffmpeg-cli-wrapper-framework"
# 源码-库目录
export g_sourceLibDir=${g_inputRootDir}/${g_libId}
# 脚本-库目录
g_scriptLibDir=${g_scriptArchDir}/${g_libId}
# Build-库目录
export g_buildLibDir=${g_buildArchDir}/${g_libId}
if [[ ! -e ${g_buildLibDir} ]]; then
    mkdir -p ${g_buildLibDir}
fi

# Output-库目录
export g_outputLibDir=${g_outputArchDir}/${g_libId}
if [[ ! -e ${g_outputLibDir} ]]; then
    mkdir -p ${g_outputLibDir}
fi

customConfigure() {
    unset CC
    iosCmake=$g_inputRootDir/ios/iOS.cmake
    #arch64为OS64
    PLATFORM="OS64"
    RELEASE=211
    VERSION=1.1.1
    cmake $g_inputPlatformDir/ffmpeg_cli_wrapper_framework \
        -G Xcode -DCMAKE_TOOLCHAIN_FILE=$iosCmake \
        -DPLATFORM=${PLATFORM} \
        -DDEPLOYMENT_TARGET=8.0 \
        -DENABLE_ARC=0 \
        -DENABLE_VISIBILITY=1 \
        -DENABLE_BITCODE=0 \
        -DARCHS=$g_arch \
        -DRELEASE=${RELEASE} \
        -DVERSION=${VERSION} \
        -DCMAKE_INSTALL_PREFIX=$g_outputLibDir \
        -DWRAPPER_INCLUDE_DIR=$g_outputArchDir/ffmpeg-cli-wrapper/include \
        -DFFMPEG_LIB=$g_outputArchDir/ffmpeg-4.2-ugc/lib/libffmpeg.a \
        -DLIBX264_LIB=$g_outputArchDir/x264/lib/libx264.a \
        -DSDL_LIB=$g_outputArchDir/sdl2-2.0.10-ugc/lib/libSDL2.a \
        -DWRAPPER_LIB=$g_outputArchDir/ffmpeg-cli-wrapper/lib/libffmpeg_cli_wrapper.a
}

function customMake() {
    cmake --build . -j 4 --target install --config ${CMAKE_CONFIG}
}